package com.ranjiaqi.lambda;

import com.ranjiaqi.pojo.Person;

import java.util.Set;
import java.util.TreeSet;

/**
 * @ClassName TestLambda02
 * @Description TODO
 * @Author hp
 * @Date 2021/7/5 14:50
 * @Version 1.0
 **/
public class TestLambda02 {
    public static void main(String[] args) {
        Set<Person> people = new TreeSet<>( (Person p1,Person p2)->{
            return p1.getAge() - p2.getAge() ;
        });

        people.add(new Person("张三", 20));
        people.add(new Person("李四", 20));
        people.add(new Person("王五", 20));
        people.add(new Person("赵六", 20));
        people.add(new Person("张三", 18));

        System.out.println(people);
    }
}
